Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

numeric-quantity

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

numeric-quantity

Number parser with support for mixed numbers and vulgar fractions

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29K
increased by84.18%
Maintainers
1
Weekly downloads
 
Created
Source

numeric-quantity

npm version workflow status codecov.io downloads MIT License

Converts a string to a number. The string can include mixed numbers or vulgar fractions.

For the inverse operation (converting a number to an imperial measurement), check out format-quantity.

For a more complete solution to parsing recipe ingredients, try parse-ingredient.

Installation

npm

# npm
npm i numeric-quantity

# yarn
yarn add numeric-quantity

Browser

In the browser, available as a global function numericQuantity.

<script src="https://unpkg.com/numeric-quantity"></script>
<script>
  console.log(numericQuantity('10 1/2')); // 10.5
</script>

Usage

import numericQuantity from 'numeric-quantity';

console.log(numericQuantity('1 1/2')); // 1.5
console.log(numericQuantity('2 2/3')); // 2.666

The return value will be NaN if the provided string does not resemble a number.

Keywords

FAQs

Package last updated on 16 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc